﻿using System;
using System.Net;
using __ts.Core.Api;
using __ts.Core.Session;

/*
 *  author: able
 *  @2012/2/21 14:37:25
 * 
 */
namespace __ts.Core.Service
{
    /// <summary>
    /// 
    /// </summary>
    public interface SelectorProcessor
    {
        /**
         * create a session for a freshly accepted client socket
         * @param service
         * @param clientChannel
         */
        void createSession(IoService service, Object clientSocket);

        /**
         * Bind and start processing this new server address
         * @param address local address to bind
         * @throws IOException exception thrown if any problem occurs while binding
         */
        void bindAndAcceptAddress(IoServer server, SocketAddress address);

        /**
         * Stop processing and unbind this server address
         * @param address the local server address to unbind
         * @throws IOException exception thrown if any problem occurs while unbinding
         */
        void unbind(SocketAddress address);

        /**
         * Schedule a session for flushing, will be called after a {@link IoSession#write(Object)}.
         * @param session the session to flush
         */
        void flush(AbstractIoSession session);
    }
}